package com.reform.service.impl;

import com.reform.pojo.phase.PhaseCheck;
import com.reform.mapper.PhaseCheckMapper;
import com.reform.res.Result;
import com.reform.res.ResultCode;
import com.reform.service.IPhaseCheckService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 阶段检查项目表 服务实现类
 * </p>
 *
 * @author mortale
 * @since 2021-10-11
 */
@Service
public class PhaseCheckServiceImpl extends ServiceImpl<PhaseCheckMapper, PhaseCheck> implements IPhaseCheckService {

    @Autowired
    PhaseCheckMapper phaseCheckMapper;

    @Override
    public int insertPhaseChecks(List<PhaseCheck> phaseChecks) {
        int res = 0;
        for (PhaseCheck phaseCheck : phaseChecks) {
            res = phaseCheckMapper.insert(phaseCheck);
        }
        return res;
    }

    @Override
    public void deletePhaseCheck(String phaseId) {
        Map<String, Object> map = new HashMap<>();
        map.put("pt_id", phaseId);
        phaseCheckMapper.deleteByMap(map);
    }

    @Override
    public Result updatePhaseStatus(String proId, String phaseId) {
        phaseCheckMapper.updatePhaseStatus(proId, phaseId);
        return Result.success(ResultCode.SUCCESS);
    }
}
